<template>
    <div class="cesiumview">
        <!--<el-button type="primary"  size="medium"  @click="clickComponent" round>点击组件</el-button>-->
        <CesiumMap ref="cesiummap"></CesiumMap>
        <SimpleFollowTooltip ref="toolTip"></SimpleFollowTooltip>
    </div>
</template>

<script>
    import SimpleFollowTooltip from './components/simplefollowtooltip'
    import { getAllDirName } from '@/views/tq3d/api/tqapi'
    import CesiumMap from './components/cesiummap'
    import ModelUtils from './util/modelutils'


    export default {
        name: "cesiumview",
        components: {
            CesiumMap,
            SimpleFollowTooltip
        },
        static() {
            return {}
        },
        data() {
            return {


            }
        },

        props: {

        },
        methods: {
            clickComponent(){
                cesiumViewer.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(121.2415139, 31.5771979,   1000) });
            },
            initEvent() {
                this.$bus.$off('tqpmmouseover').$on('tqpmmouseover', (msg) => {
                    const toolTip = this.$refs.toolTip;
                    if (toolTip) {
                        toolTip.text = msg.name;
                        toolTip.x = msg.x;
                        toolTip.y = msg.y;
                        toolTip.visible = msg.visible;
                        toolTip.style = '';
                    }


                });
                this.$bus.$off('tqpmmouseout').$on('tqpmmouseout', (msg) => {
                    const toolTip = this.$refs.toolTip;
                    if (toolTip) {
                        toolTip.visible = false;
                    }
                });

            },

            initUtils() {

                //window.modelUtils = new ModelUtils(this.$bus);
            },
            sortNumber(a, b) {//升序
                return a - b
            },
            locationToFactory() {
                const {Cesium, cesiumViewer} = window

                // if (cesiumViewer.homeButton) {
                //     cesiumViewer.homeButton.viewModel.command.beforeExecute.addEventListener((e) => {
                //         e.cancel = true;
                //         if (this.sceneCenterCartesian) {
                //             cesiumViewer.camera.lookAt(this.sceneCenterCartesian, new Cesium.HeadingPitchRange(0.0, Cesium.Math.toRadians(-45.0), 1200));
                //             cesiumViewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
                //         }
                //
                //     });
                // }


            },

            initModels() {


            },
            initImages(){

            }


        },

        beforeDestroy() {


        },
        activated() {

        },
        deactivated() {

        },
        mounted() {
            if (!window.initSceneData) {
                window.initSceneData = true;
                this.initUtils();
                this.initImages();
                this.locationToFactory();
                this.initModels();
            } else {
                // window.modelUtils.removeFromScene();
                // window.placeMarkutils.removeFromScene();
                // window.regionUtils.removeFromScene();
            }


        }
    }
</script>

<style scoped>

    .cesiumview {
        position: absolute;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
</style>
